$(function () {
    $(".bottom-button").on("click", function () {
        //var  url = window.location.href;
        if(this.id=='up'){
            chapterInfo.chapterUrl=chapterInfo.pageUp;
            chapterInfo.type = "up";//上页
            if(chapterInfo.num=='1'){
                //跳回章节列表
                chapterInfo.type="menu";
                forward("/forward/book/pageBook/bookChapterList",chapterInfo,"_self");
            }else {
                forward("/forward/book/pageBook/bookRead",chapterInfo,"_self");
            }
        }else if(this.id=='next'){
            chapterInfo.chapterUrl=chapterInfo.pageDown;
            chapterInfo.type = "down";//下页
            if(chapterInfo.last=='1'){
                //跳回章节列表
                chapterInfo.type="menu";
                forward("/forward/book/pageBook/bookChapterList",chapterInfo,"_self");
            }else {
                forward("/forward/book/pageBook/bookRead",chapterInfo,"_self");
            }

        }else if(this.id=='menu'){
            chapterInfo.type="menu";
            forward("/forward/book/pageBook/bookChapterList",chapterInfo,"_self");
        }

    });


});
/*书籍下载*/
function downLoadFile(url,data){
    //统一处理 相间为json数据 页面跳转+数据传递 默认Post方式
    var data = JSON.stringify(data);
    var tempForm = document.createElement("form");
    tempForm.id = "tempForm1";
    tempForm.method = "post";
    tempForm.action = url;//接口

    tempForm.target = "_blank";    // _blank - URL加载到一个新的窗口
    var hideInput = document.createElement("input");
    hideInput.type = "hidden";
    hideInput.name = "content";
    hideInput.value = data;
    tempForm.appendChild(hideInput);
    // 可以传多个参数
    if(document.all){    // 兼容不同浏览器
        tempForm.attachEvent("onsubmit",function(){});        //IE
    }else{
        tempForm.addEventListener("submit",function(){},false);    //firefox
    }
    document.body.appendChild(tempForm);
    if(document.all){    // 兼容不同浏览器
        tempForm.fireEvent("onsubmit");
    }else{
        tempForm.dispatchEvent(new Event("submit"));
    }
    tempForm.submit();
    document.body.removeChild(tempForm);
}

function loadUrl (url){
    window.location.href=url
}
function theme(){
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            type: 2,
            title: '',
            shadeClose: true,
            closeBtn: 0,
            shade: 0.8,
            area: ['900px', '600px'],
            content: '/alert/book/theme'
        });
    });

}

function ruleSet(){
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            type: 2,
            title: '',
            shadeClose: true,
            closeBtn: 0,
            shade: 0.8,
            area: ['900px', '600px'],
            content: '/alert/book/bookRule'
        });
    });

}
/*跳转view*/
function  forward(url,data,target){
   var t="_self";
    if(arguments.length == 2){
        t="_blank";
    }else {
        t="_self";
    }
    //统一处理 相间为json数据 页面跳转+数据传递 默认Post方式
    var data = JSON.stringify(data);
    var tempForm = document.createElement("form");
    tempForm.id = "tempForm1";
    tempForm.method = "post";
    tempForm.action = url;//接口

    tempForm.target = t;    // _blank - URL加载到一个新的窗口
    var hideInput = document.createElement("input");
    hideInput.type = "hidden";
    hideInput.name = "content";
    hideInput.value = data;
    tempForm.appendChild(hideInput);
    // 可以传多个参数
    if(document.all){    // 兼容不同浏览器
        tempForm.attachEvent("onsubmit",function(){});        //IE
    }else{
        tempForm.addEventListener("submit",function(){},false);    //firefox
    }
    document.body.appendChild(tempForm);
    if(document.all){    // 兼容不同浏览器
        tempForm.fireEvent("onsubmit");
    }else{
        tempForm.dispatchEvent(new Event("submit"));
    }
    tempForm.submit();
    document.body.removeChild(tempForm);
}